<template>
  <div class="vehicle-details-wrap">
    <div class="box">
      <TopFilter
        ref="searchOrdersPanel"
        :list="searchOrdersList"
        :isSubmitBtn="true"
        :cols="4"
        :label-width="90"
        @filterChange="getOrderList"
        @onCollapse="collapseHandle"
      />
      <!-- <el-row>
        <el-button @click="query" type="primary" >查 询</el-button>
        <el-button @click="reset" >重 置</el-button>
      </el-row> -->
       <!--  :loading="addBtnState" -->
    </div>
    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      selectionType="multiple"
      :datakey="'rows'"
      :onColumnsChange="columns => this.columns = columns"
      :onRowSelectChange="arr => this.onChangeColumn = arr"
    >
      <template slot="controls">
        <!-- <el-button @click="openPayments" type="primary" >收 款</el-button> -->
      </template>
    </FilterTable>
  </div>
</template>

<script>
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
import { getOrderList } from '@/api/finance/repair/receivables';



export default {
  name: 'claimDailyboard',
  mixins: [dictionary],
  data() {
    // this.dmsFunc = { dmsFuncId: 55100010 };
    return {
      searchOrdersList: this.createSearchOrdersList(),
      columns: this.createTableColumns(),
      fetchParams: { },
      fetchApi: getOrderList,
      onChangeColumn: [],
    };
  },
  components: {},
  computed: {},
  watch: {},
  methods: {
    createSearchOrdersList() {
      return [
        {
          type: 'INPUT',
          label: '工单号',
          fieldName: 'roNo'
        },
        {
          type: 'SELECT',
          label: '是否结清',
          fieldName: 'payOff',
          itemList: this.createDictList('1004')
        }
      ];
    },
    createTableColumns(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 50,
          fixed: 'left',
          render: props => {
            return (
              <div>
                <el-button size="mini" type="text">
                  操作
                </el-button>
              </div>
            );
          }
                // <el-divider direction="vertical" />
                // <el-button size="mini" type="text" onClick={()=>this.detail(props.row)}>
                //   明细
                // </el-button>
                // <el-divider direction="vertical" />
                // <el-button size="mini" type="text" disabled={props.row.lockFlag === 10041002} onClick={()=>this.removelock(props.row.employeeId)}>
                //   解锁
                // </el-button>
                // <el-divider direction="vertical" />
                // <el-button size="mini" type="text" disabled={props.row.lockFlag === 10041001} onClick={()=>this.lock(props.row.employeeId)}>
                //   锁定
                // </el-button>
        },
        {
          title: '经销商',
          // dataIndex: 'dealer',
          sorter: true,
        },
        {
          title: '结算日期',
          dataIndex: 'BALANCE_TIME',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: 'VIN',
          dataIndex: 'VIN',
          sorter: true,
        },
        {
          title: '维修类型',
          dataIndex: 'REPAIR_TYPE_CODE',
          sorter: true,
          // render: props => {
          //   return <span>{this.createDictText(props.row.REPAIR_TYPE_CODE, '8000')}</span>;
          // }
        },
        {
          title: '工单号',
          dataIndex: 'RO_NO',
          sorter: true,
        },
        {
          title: '工单开单日期',
          dataIndex: 'RO_CREATE_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '进厂里程数',
          dataIndex: 'IN_MILEAGE',
          sorter: true,
        },
        {
          title: '索赔单号',
          dataIndex: 'CLAIM_NO',
          sorter: true,
        },
        {
          title: '车牌号',
          dataIndex: 'LICENSE',
          sorter: true,
        },
        {
          title: '车主名称',
          dataIndex: 'OWNER_NAME',
          sorter: true,
        },
        {
          title: '车主电话',
          dataIndex: 'PHONE',
          sorter: true,
        },
        {
          title: '车主手机',
          dataIndex: 'MOBILE',
          sorter: true,
        },
        {
          title: '工时费',
          dataIndex: 'LABOUR_AMOUNT',
          sorter: true,
        },
        {
          title: '材料费',
          dataIndex: 'PART_SALES_AMOUNT',
          sorter: true,
        },
        {
          title: '材料管理费（辅料）',
          dataIndex: 'OVER_ITEM_AMOUNT',
          sorter: true,
        },
        {
          title: '索赔管理费',
          sorter: true,
          render: props => {
            return <span>{props.row.PART_SALES_PRICE*0.15>1?1*1:props.row.PART_SALES_PRICE*0.15*1}</span>;
          }
           //单车毛利参数  配件数量
        },
        {
          title: '附加费用',
          dataIndex: 'ADD_ITEM_AMOUNT',
          sorter: true,
        },
        {
          title: '合计费用',
          sorter: true,
          render: props => {
            return <span>{props.row.LABOUR_AMOUNT+props.row.PART_SALES_AMOUNT+props.row.OVER_ITEM_AMOUNT+props.row.ADD_ITEM_AMOUNT}</span>;
          }
        },
        {
          title: '服务专员',
          dataIndex: 'SERVICE_ADVISOR',
          sorter: true,
        },
        {
          title: '维修技师',
          dataIndex: 'TECHNICIAN',
          sorter: true,
        },
        {
          title: '制造日期',
          dataIndex: 'PRODUCT_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '销售日期',
          dataIndex: 'SALES_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '是否结清',
          dataIndex: 'PAY_OFF',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.BALANCE_CLOSE, '1004')}</span>;
          }
        },

      ]
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.$refs.table.$refs.pageTable.EXECUTE_RESET_HEIGHT();
      });
    },
    async getReceiveDetail(id) {
      const res = await getReceiveDetail(id);
      // console.log(res,'结清')
      this.showWriteOff = true
      this.$nextTick(()=>{
        this.$refs.writeOff.openModel(this.onChangeColumn, res.data)
      })
    },
    getOrderList (val){
      this.fetchParams = Object.assign({}, val);
    },
  },
  mounted() {
    // this.query()
  }
};
</script>

<style lang="less">
</style>
